﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace RestfulApi.Filters
{
    public class MyResourceFilterAttribute : Attribute, IResourceFilter
    {
        public MyResourceFilterAttribute(ILogger<MyResourceFilterAttribute> logger)
        {
            Logger = logger;
        }

        public ILogger<MyResourceFilterAttribute> Logger { get; }

        public void OnResourceExecuted(ResourceExecutedContext context)
        {
            //Logger.LogInformation("OnResourceExecuted executes.");
            //throw new Exception("OnResourceExecuted"); 不能
        }

        public void OnResourceExecuting(ResourceExecutingContext context)
        {
            //Logger.LogInformation("OnResourceExecuting executes.");
            // throw new Exception("OnResourceExecuting"); 不能
        }
    }
}
